﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace Group_Project_Book_Store
{
    class clsHelper
    {   
        /// <summary>
        /// Get the style from the resources
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static Style GetStyle(string key)
        {
            try
            {
                var resource = Application.Current.FindResource(key);
                return resource as Style;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }
        }
        /// <summary>
        /// Static List to convert currency
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public static int ConvertCurrenyToInt(string number)
        {
            try
            {
                 return Convert.ToInt32(number.ToString().Replace(".00", "").Replace("$", "").Trim());
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
                return 0;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public static string ConvertStringToCurreny(int number)
        {
            try
            {
                return "$ " + number.ToString() + ".00";
            }
            catch (Exception ex)
            {
                
                MessageBox.Show(ex.Message);
                return null;
            }
        }
        /// <summary>
        /// Static List to convert currency
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public static List<string> ConvertStringToCurreny(List<int> number)
        {
            try
            {
                return number.Select(n => "$ " + n.ToString() + ".00").ToList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }
        }
    }
}
